#pragma once

#include <Crawler/PluginRoot.h>
#include <Crawler/AbstractReplyFilter.h>
#include <Crawler/AbstractUrlFilter.h>
#include <Crawler/Plugin.h>




class CoreFilter
	: public PluginRoot
	, public AbstractReplyFilter
	, public AbstractUrlFilter
{
private:

	static const QString m_name;
	static const QString m_description;
	static const QString m_version;

private:

	bool          m_enabled;

	/// This is the list of content-types that we do accept
	QStringList   m_contentTypes;

	/// A list of all Urls, that have passed the tests
	QSet<QUrl>    m_acceptedUrls;

public:

	CoreFilter();



	/**
	 * Get the name of the Filter.
	 * @see Plugin::name
	 */
	QString name() const;

	/**
	 * Get a formatted version string.
	 * @see Plugin::version
	 */
	QString version() const;

	/**
	 * Get a description of the Filter.
	 * @see Plugin::description
	 */
	QString description() const;



	/**
	 * Test if the given reply can be given to the analyzer or not.
	 *
	 * @param reply    the reply to test
	 *
	 * @return true    when reply passed the test
	 * @return false   when it didn't: it will be discarded instead
	 *
	 * @see AbstractReplyFilter::filterReply
	 */
	bool filterReply( const QNetworkReply *reply ) const;



	/**
	 * Test if the given Url shall be fed to the Crawler or not.
	 *
	 * @param url      the Url to test
	 *
	 * @return true    when Url passed the test
	 * @return false   when it didn't: it will be discarded instead
	 *
	 * @see AbstractUrlFilter::filterUrl
	 */
	bool filterUrl( const QUrl &url ) const;

	/**
	 * Simply indicates that the following Url passed the test of each
	 * filter. The Filter may do whatever it wants (for example keep
	 * track of all approved urls).
	 *
	 * @param url   the Url that passed all tests
	 *
	 * @see AbstractUrlFilter::urlPassed
	 */
	void urlPassed( const QUrl &url );



	/**
	 * Enable the plugin.
	 * @see Plugin::enable
	 */
	void enable();

	/**
	 * Disable the plugin.
	 * @see Plugin::disable
	 */
	void disable();



	/**
	 * Test if the plugin is enabled or not.
	 * @see Plugin::enabled
	 */
	bool enabled() const;

	/**
	 * Test if the plugin is disabled or not.
	 * @see Plugin::disabled
	 */
	bool disabled() const;
};
///////////////////////////////////////////////////////////////////////////////////////////////////




extern "C" __declspec( dllexport ) PluginRoot *createPlugin();
extern "C" __declspec( dllexport ) void releasePlugin( PluginRoot *object );
